<?php
use think\Route;

//test
Route::get(':version/test/:id', 'admin/:version.Admin/getAuthList');

//管理员
Route::group(':version/admin', function () {
    Route::get('', 'admin/:version.Admin/getAll');
    Route::get('/:id', 'admin/:version.Admin/getById', [], ['id' => '\d+']);
    Route::post('', 'admin/:version.Admin/createOne');
    Route::put('/:id', 'admin/:version.Admin/updateSelf');
    Route::put('/:id', 'admin/:version.Admin/updateOne', [], ['id' => '\d+']);
    Route::delete('/:id', 'admin/:version.Admin/deleteOne', [], ['id' => '\d+']);
});

//管理员角色
Route::group(':version/admin_role', function () {
    Route::post('', 'admin/:version.Admin/matchRole');
    Route::delete('', 'admin/:version.Admin/unMatchRole');
});

//资源
Route::group(':version/source', function () {
    Route::get('', 'admin/:version.Source/getAll');
    Route::get(':/id', 'admin/:version.Source/getById', [], ['id' => '\d+']);
    Route::post('', 'admin/:version.Source/createOne');
    Route::put('/:id', 'admin/:version.Source/updateOne', [], ['id' => '\d+']);
    Route::delete('/:id', 'admin/:version.Source/deleteOne', [], ['id' => '\d+']);
});


//permissions权限
Route::group(':version/permission', function () {
    Route::post('', 'admin/:version.Permission/createOne');
    Route::delete('/:id', 'admin/:version.Permission/deleteOne', [], ['id' => '\d+']);
});


//角色
Route::group(':version/role', function () {
    Route::get('', 'admin/:version.Role/getAll');
    Route::get(':/id', 'admin/:version.Role/getById', [], ['id' => '\d+']);
    Route::post('', 'admin/:version.Role/createOne');
    Route::put('/:id', 'admin/:version.Role/updateOne', [], ['id' => '\d+']);
    Route::delete('/:id', 'admin/:version.Role/deleteOne', [], ['id' => '\d+']);
});


//adminToken
Route::group(':version/token', function () {
    Route::post('', 'admin/:version.Token/getToken');
});

//文章
Route::group(':version/article', function () {
    Route::get('', 'admin/:version.Article/getAll');
    Route::get('/:id', 'admin/:version.Article/getById', [], ['id' => '\d+']);
    Route::post('', 'admin/:version.Article/createOne');
    Route::put('/:id', 'admin/:version.Article/updateOne', [], ['id' => '\d+']);
    Route::delete('/:id', 'admin/:version.Article/deleteOne', [], ['id' => '\d+']);
});

//产品

Route::group(':version/product', function () {
    Route::get('', 'admin/:version.Product/getAll');
    Route::get('/:id', 'admin/:version.Product/getById', [], ['id' => '\d+']);
    Route::post('', 'admin/:version.Product/createOne');
    Route::put('/:id', 'admin/:version.Product/updateOne', [], ['id' => '\d+']);
    Route::post('/:id', 'admin/:version.Product/updateOne', [], ['id' => '\d+']);
    Route::delete('/:id', 'admin/:version.Product/deleteOne', [], ['id' => '\d+']);
});
//产品拼图
Route::group(':version/product/:id/piece', function () {
    Route::post('', 'admin/:version.Product/updatePiece',[],['id'=>'\d+']);
});


//拼图
Route::group('/piece', function () {
    Route::get('/:id', 'index/ProductPiece/getById', [], ['id' => '\d+']);
    Route::post('', 'index/ProductPiece/createOne');
    Route::put('/:id', 'index/ProductPiece/updateOne', [], ['id' => '\d+']);
    Route::delete('/:id', 'index/ProductPiece/deleteOne', [], ['id' => '\d+']);
});


//用户
Route::group(':version/user', function () {
    Route::get('', 'admin/:version.User/getAll');
    Route::get('/:id', 'admin/:version.User/getById', [], ['id' => '\d+']);
    Route::post('', 'admin/:version.User/createOne');
    Route::put('/:id', 'admin/:version.User/updateOne', [], ['id' => '\d+']);
    Route::delete('/:id', 'admin/:version.User/deleteOne', [], ['id' => '\d+']);
});

//用户产品
Route::group(':version/exchange/user', function () {
    Route::get('/:user_id', 'admin/:version.Exchange/getByUserId',[],['user_id'=>'\d+']);
});


//兑换
Route::group(':version/exchange', function () {
    Route::get('', 'admin/:version.Exchange/getAll');
    Route::post('/statistics', 'admin/:version.Exchange/statistics');
});

//门店
Route::group(':version/store', function () {
    Route::get('', 'admin/:version.Store/getAll');
    Route::post('', 'admin/:version.Store/createOne');
});


//统计
Route::group(':version/Statistic', function () {
    Route::get('/:func', 'admin/:version.Statistic/:func');
});

//页面
Route::group(':version/Page', function () {
    Route::get('', 'admin/:version.Page/getAll');
    Route::post('/:id', 'admin/:version.Page/updateOne',[],['id'=>'\d+']);
});